package suanfati;
/**
 * 判断数组中是否有重复元素
 */

import java.util.*;

public class IsRepeatable {
    public static void main(String[] args) {
        int [] a = {4,73,5,6,4,7,3,4,7};
    isRepeated2(a);
    }
    private static void isRepeated2(int[] a) {
        List b = new ArrayList<>();
        for (int i : a) {
            if (b.contains(i)){
                System.out.println("数组有重复元素");
                break;
            }else {
            b.add(i);
            }
        }
    }
    private static void IsRepeated1(int[] a) {
        Arrays.sort(a);
        int [] ary = new int[a[a.length-1]];
        for (int i : a) {
            ary [i]++;
            if (ary[i]==2){
                System.out.println("数组有重复的元素");
                break;
            }
        }
    }
}
